package com.itheima.a01mathdemo01;

/***
 *@title MathDemo02
 *@description <TODO description class purpose>
 *@author 12468
 *@version 1.0.0
 *@create 2024-11-13 21:19
 **/
public class MathDemo02 {
    public static void main(String[] args) {
        // 判断一个书是否质数
        System.out.println(isPrime(10));
        System.out.println(isPrime(13));

        System.out.println(isPrime(997));

    }
    // 方法一：
    public static boolean isPrime(int number) {
        for (int i = 2; i < number; i++) {
            if(number % i == 0) {
                return false;
            }
        }
        return true;
    }
    // 方法二：
    public static boolean isPrime2(int number) {
        for (int i = 2; i < Math.sqrt(number); i++) {
            if(number % i == 0) {
                return false;
            }
        }
        return true;
    }
}
